package com.bone.order.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bone.business.po.Business;
import com.bone.common.BaseIbatisDAO;
import com.bone.order.po.OrdOrder;
import com.bone.page.Page;


/**
 * DAO.
 * @author liwenzhan
 *
 */
public class OrdOrderDAO extends BaseIbatisDAO {

	
	
	/**
	 * 取符合查询条件的数据.
	 * @param parameter
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public Page<OrdOrder> queryOrderPageByParam(Map<String, Object> para,Page page){     
		Long totalResultSize = (Long) getSqlMapClientTemplate().queryForObject("ORD_ORDER.queryCountByParam", para);
		page.setTotalResultSize(totalResultSize);				
		para.put("startRows", page.getStartRows());				
		para.put("endRows", page.getEndRows());
		para.put("_order", "order_id");
		page.setItems(getSqlMapClientTemplate().queryForList("ORD_ORDER.queryPageByParam", para));
		return page;
	}
	

	/**
	 * 取符合条件的模块的数量.
	 * @param para
	 * @return
	 */
	public Long queryOrderCountByParam(Map<String, Object> para){
		return (Long) getSqlMapClientTemplate().queryForObject("ORD_ORDER.queryCountByParam", para);
		
	}
	
	/**
	 * 
	 * @param parameter
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<OrdOrder> queryOrderListByParam(Map<String, Object> parameter){
		return getSqlMapClientTemplate().queryForList("ORD_ORDER.queryPageByParam", parameter);
	}
	
	/**
	 * 
	 * @param orderId
	 * @return
	 */
	public OrdOrder queryOrderById(Long orderId){     
		 return (OrdOrder)this.getSqlMapClientTemplate().queryForObject("ORD_ORDER.queryOrderById", orderId);
	}
	
	/**
	 * 
	 * @param orderNo
	 * @return
	 */
	public OrdOrder queryOrderByOrderNo(String orderNo){     
		 return (OrdOrder)this.getSqlMapClientTemplate().queryForObject("ORD_ORDER.queryOrderByOrderNo", orderNo);
	}
	
	
	public int updateByOrderNo(final OrdOrder record) {
		int rows = getSqlMapClientTemplate().update("ORDER.updateByOrderNo",record);
		return rows;
	}

	/**
	 * .
	 * @param objectId
	 * @return
	 */
	public OrdOrder queryOrderByParam(final OrdOrder ordOrder){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("orderNo", ordOrder.getOrderNo());
		map.put("orderStatus", ordOrder.getOrderStatus());
		map.put("orderType", ordOrder.getOrderType());
		return  (OrdOrder) super.getSqlMapClientTemplate().queryForObject("OREORDER.queryOrderListByParam", map);
	}
	
	

}
